package com.micro.frog.rbac;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;

/**
 * * @EnableFeignClients 必不可少，使用此注解才能扫描到 Feign 接口，负责不会注入 Beans
 * * @EnableFeignClients 与 @ComponentScan 有冲突
 * 如果两种注解都使用时，其中 @EnableFeignClients 会覆盖 @ComponentScan 中指定的目录，从而恢复到默认目录
 * 解决方案 1.可以将 bean 放在和 main 启动类同级目录 2.可以在 @EnableFeignClients 中指定bean目录
 *
 * @author :  ljh
 * @since : 2018/3/29
 **/
@EnableCaching
@ComponentScan(basePackages = {"com.micro.frog.rbac.*"})
@SpringBootApplication(scanBasePackages = {"com.micro.frog.rbac"})
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"com.micro.frog"})
public class RbacApplication extends SpringBootServletInitializer {
    public static void main(String[] args) {
        SpringApplication.run(RbacApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(RbacApplication.class);
    }
}
